Mac实现iTerm2 免登录ssh服务器

没图自己想象

在你电脑的任意位置创建自动登录的脚本

  1. touch itermSsh.sh
  2. vim itermSsh.sh
  3. shell
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    #!/usr/bin/expect -f
    set user _user
    set host _host
    set password _password
    set timeout -1
    spawn ssh $user@$host
    expect "*assword:*"
    send "$password\r"
    interact
    expect eof

tip:替换_user用户名, _host服务器地址, _password密码

  1. 打开iTerm的Preferences -> 切换到Profiles Tab -> new profile -> 在Command那一个输入框内写上itermSsh.sh的路径就可以。

  2. 然后new Tab的时候选择你创建的profile

Copyright © 2017 - 2024 Timbok's Blog All Rights Reserved.

访客数 : | 访问量 :